package services

import (
	context "context"

	_ "google.golang.org/grpc"
)

type ProdService struct {
}

func selectStock(areas ProdAreas) int32 {
	switch areas {
	case ProdAreas_A:
		return 40
	case ProdAreas_B:
		return 41
	case ProdAreas_C:
		return 42
	default:
		return 88
	}
}
func (this *ProdService) GetProdStock(ctx context.Context, request *ProdRequest) (*ProdResponse, error) {
	return &ProdResponse{ProdStock: selectStock(request.GetProdAreas())}, nil
}

func (this *ProdService) GetProdStocks(ctx context.Context, size *QuerySize) (*ProdResponseList, error) {
	ProdRes := []*ProdResponse{
		&ProdResponse{ProdStock: 28},
		&ProdResponse{ProdStock: 29},
		&ProdResponse{ProdStock: 30},
		&ProdResponse{ProdStock: 31},
	}
	return &ProdResponseList{
		ProdRes: ProdRes,
	}, nil
}

func (this *ProdService) GetProdInfo(context.Context, *ProdRequest) (*ProdModel, error) {
	return &ProdModel{
		ProdId:    12,
		ProdName:  "加多宝",
		ProdPrice: 5.0,
	}, nil
}
